#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb emplace_back
#define ld long double
#define cmax(a,b) ((a)=max((a),(b)))
#define cmin(a,b) ((a)=min((a),(b)))
using namespace std;
namespace IO{
	const int maxn=(1<<20);char *p1,*p2,buf[maxn];
	#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++)
	int read(){
		int f=1,k=0;char c;
		while(!isdigit(c=gc()))if(c=='-')f=-1;
		while(isdigit(c))k=k*10+c-48,c=gc();
		return f*k;
	}
	void write(int k,char c){
		if(k<0){putchar('-');k=-k;}
		char st[21];int top=0;
		do{st[++top]=(k%10)|48,k/=10;}while(k);
		while(top)putchar(st[top--]);
		putchar(c);
	}
}using namespace IO;
const int N=500+10,inf=0x3f3f3f3f3f3f3f3f;
set<pii> S;
int q,x,y;
char op;
map<pii,int> cnt;
pii calc(pii x,pii y){
	if(x.fi>y.fi)swap(x,y);
	return {max(0ll,x.se<y.se?x.se-y.fi:y.se-y.fi),max(x.se,y.se)-x.fi};
}
int Gans(){
	if(S.size()==1){
		pii k=*S.begin();
		return k.se-k.fi;
	}
	pii ans={inf,inf};
	for(auto a:S)
		for(auto b:S)
			ans=min(ans,calc(a,b));
	return ans.se;
}
namespace OutRange{
	multiset<pii> ans;
	void add(pii k){
		ans.insert({k.se-k.fi,k.se-k.fi});
		S.insert(k);auto it=S.find(k);
		if(S.size()==1)return;
		if(it!=S.begin()&&next(it)!=S.end()){
			ans.erase({0ll,((*prev(it)).fi)});
			ans.insert({0ll,(*it).se-((*prev(it)).fi)});
			ans.insert({0ll,(*next(it)).se-(*it).fi});
			return;
		}
		if(it==S.begin())ans.insert({0ll,(*next(it)).se-(*it).fi});
		else ans.insert({0ll,(*it).se-((*prev(it)).fi)});
	}
	void del(int a,int b){
		auto it=ans.find({a,b});
		ans.erase(it);
	}
	void del(pii k){
		del(k.se-k.fi,k.se-k.fi);
		auto it=S.find(k);
		if(it!=S.begin()&&next(it)!=S.end()){
			ans.insert({0ll,((*prev(it)).fi)});
			del(0ll,(*it).se-((*prev(it)).fi));
			del(0ll,(*next(it)).se-(*it).fi);
			return;
		}
		if(it==S.begin())del(0ll,(*next(it)).se-(*it).fi);
		else del(0ll,(*it).se-((*prev(it)).fi));
		S.erase(k);
	}
	void solve(){
		while(q--){
			while((op=gc())!='A'&&op!='R');
			x=read(),y=read();
			if(op=='A') add({x,y});
			else del({x,y});
			write((*ans.begin()).se,'\n');
		}
	}
}
signed main(){
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	q=read();
	if(q>500)return OutRange::solve(),0;
	while(q--){
		while((op=gc())!='A'&&op!='R');
		x=read(),y=read();
		if(op=='A'){
			S.insert({x,y});
			++cnt[{x,y}];
		}
		else {
			if(!--cnt[{x,y}])
				S.erase({x,y});
		}
		write(Gans(),'\n');
	}
	return 0;
}
